/*******************************************************************************
 * The MOSES project, model based software engineering of networked embedded systems.
 * 
 * Copyright (C) 2010-2013, University of Applied Sciences Wildau,
 * Telematics Research Group, http://www.tm.th-wildau.de/research-group
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 * 
 * Contributors:
 *     University of Applied Sciences Wildau - initial API and implementation
 * 
 * If you are interested in a commercial license please contact us via 
 * e-mail: ralf.vandenhouten@th-wildau.de.
 ******************************************************************************/
package de.thwildau.tm.moses.examples.nmea.data;


import de.thwildau.tm.moses.abnf.io.AbnfCoder;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Deprecated
public class Appower extends Nmea {

	// begin field section
	/** field for rule alphas */
	private String alphas;
	/** field for rule voltage */
	private Float voltage;
	/** field for rule amps */
	private Integer amps;
	/** field for rule battery */
	private Integer battery;
	// end field section
	
	public Appower() {
		this.alphas = "APPOWER";
	}

	// begin setter getter section
	public void setAlphas(String alphas) {
		this.alphas = alphas;
	}

	public String getAlphas() {
		return this.alphas;
	}

	public void setVoltage(float voltage) {
		this.voltage = voltage;
	}

	public float getVoltage() {
		return this.voltage;
	}
	
	public void setAmps(Integer amps) {
		this.amps = amps;
	}

	public Integer getAmps() {
		return this.amps;
	}

	public void setBattery(Integer battery) {
		this.battery = battery;
	}

	public Integer getBattery() {
		return this.battery;
	}
	// end setter getter section

	@Override
	public void read(DataInput in) throws IOException {
		this.voltage = AbnfCoder.decodeUntil(in, ",", Float.class);
		this.amps = AbnfCoder.decodeUntil(in, ",", Integer.class);
		this.battery = AbnfCoder.decodeUntil(in, ",", Integer.class);
	}

	@Override
	public void write(DataOutput out) throws IOException {
		AbnfCoder.encode(out, "$");
		AbnfCoder.encode(out, alphas);
		AbnfCoder.encode(out, ",");
		AbnfCoder.encode(out, Float.toString(voltage));
		AbnfCoder.encode(out, ",");
		AbnfCoder.encode(out, amps);
		AbnfCoder.encode(out, ",");
		AbnfCoder.encode(out, battery);
		AbnfCoder.encode(out, ",");
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("$").append(alphas);
		builder.append(",").append(voltage);
		builder.append(",").append(amps);
		builder.append(",").append(battery);
		builder.append(",");
			return builder.toString();
		}
}
